package com.ineatconseil.yougo.client.ui.main.application.tabs;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.ineatconseil.yougo.client.cto.UserCTO;
import com.ineatconseil.yougo.client.ui.common.ClientFactory;
import com.ineatconseil.yougo.client.ui.main.application.tabs.requestTypesMngt.RequestTypesActivity;
import com.ineatconseil.yougo.client.ui.main.application.tabs.requestsMngt.RequestsActivity;
import com.ineatconseil.yougo.client.ui.main.application.tabs.requestsMngt.RequestsPlace;
import com.ineatconseil.yougo.client.ui.main.application.tabs.requestsValidationMngt.RequestsValidationActivity;
import com.ineatconseil.yougo.client.ui.main.application.tabs.userTypesMngt.UserTypesActivity;
import com.ineatconseil.yougo.client.ui.main.application.tabs.usersMngt.UsersActivity;

/**
 * @author Benjamin Barbier - Ineat Conseil
 */
public class TabsActivity extends AbstractActivity implements ITabsView.Presenter {

	private final ClientFactory clientFactory;
	
	public TabsActivity(ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
	}
	
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		System.out.println("TabsActivity.start()");
		
		ITabsView tabsView = clientFactory.getTabsView();
		tabsView.setPresenter(this);
		
		//TODO: fill the good UserCTO here :
		UserCTO userCTO = (UserCTO) UserCTO.createObject();
		userCTO.setId(1);
		
		//TODO: Fill the places here.
		tabsView.addTab(clientFactory.getRequestsView(), 
				"Mes Demandes",  new RequestsActivity(new RequestsPlace(userCTO), clientFactory));
		tabsView.addTab(clientFactory.getRequestsValidationView(), 
				"Valider des demandes", new RequestsValidationActivity(null, clientFactory));
		tabsView.addTab(clientFactory.getUsersView(), 
				"Gérer les utilisateurs", new UsersActivity(null, clientFactory) );
		tabsView.addTab(clientFactory.getUserTypesView(), 
				"Gérer les types d'utilisateurs", new UserTypesActivity(null, clientFactory));
		tabsView.addTab(clientFactory.getRequestTypesView(), 
				"Gérer les types de demandes", new RequestTypesActivity(null, clientFactory));
		
	}

	@Override
	public void goTo(Place place) {
		clientFactory.getPlaceController().goTo(place);
	}

}
